<?php 
//$db = "w4111b.cs.columbia.edu:1521/adb"; 
 
//$conn = oci_connect("gip2103", "rdVICpH", $db);  

$conn=oci_connect("gaurav","gaurav","xe");
$msgid='3';
session_start(); 
//$user=$_SESSION['username'];
$user='gip2103';
$lat='0';
$long='0';

//do_query($conn, 'SELECT * FROM Messages where messageid = '.$msgid.' order by MessageId asc');

//do_query($conn, "SELECT fromcuid,mesg FROM Messages where tocuid like '$user' order by MessageID asc");

do_query($conn, "SELECT C.fname,C.lname,M.fromcuid,M.mesg FROM Messages M,Candidate C where M.tocuid like '$user' and M.fromcuid=C.cuid order by M.MessageID asc");
	
// Execute query and display results 
function do_query($conn, $query)
{
  $stid = oci_parse($conn, $query);
  $r = oci_execute($stid, OCI_DEFAULT);

  print '<table border="1">';
  while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    print '<tr>';
    foreach ($row as $item) {
      print '<td>'.
            ($item ? htmlentities($item) : '&nbsp;').'</td>';
    }
    print '</tr>';
  }
  print '</table>';
}
?>